const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('sp_permission', {
    ps_id: {
      autoIncrement: true,
      type: DataTypes.SMALLINT.UNSIGNED,
      allowNull: false,
      primaryKey: true
    },
    ps_name: {
      type: DataTypes.STRING(20),
      allowNull: false,
      comment: "权限名称"
    },
    ps_pid: {
      type: DataTypes.SMALLINT.UNSIGNED,
      allowNull: false,
      comment: "父id"
    },
    ps_c: {
      type: DataTypes.STRING(32),
      allowNull: false,
      defaultValue: "",
      comment: "控制器"
    },
    ps_a: {
      type: DataTypes.STRING(32),
      allowNull: false,
      defaultValue: "",
      comment: "操作方法"
    },
    ps_level: {
      type: DataTypes.ENUM('0','2','1'),
      allowNull: false,
      defaultValue: "0",
      comment: "权限等级"
    }
  }, {
    sequelize,
    tableName: 'sp_permission',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "ps_id" },
        ]
      },
    ]
  });
};
